{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.3"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3",
   "language": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "# `break` 、 `continue` 和 `pass`"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "## `break`\n",
    "\n",
    "`break` 用来立即退出循环语句（包括 `else`）"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "i = 0\n",
    "while i < 5:\n",
    "    if i == 3:\n",
    "        break\n",
    "    print(i)\n",
    "    i += 1\n",
    "else:\n",
    "    print('Hello World')"
   ]
  },
  {
   "source": [
    "## `continue`\n",
    "\n",
    "`continue` 可以用来跳过当此循环"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "i = 0\n",
    "while i < 5:\n",
    "    i += 1\n",
    "    if i == 3:\n",
    "        continue\n",
    "    print(i)\n",
    "else:\n",
    "    print('Hello World')"
   ]
  },
  {
   "source": [
    "## `pass`\n",
    "\n",
    "`pass` 无实际意义，用来占位"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "i = 0\n",
    "if i < 5:\n",
    "    pass"
   ]
  }
 ]
}